package demo;

/**
 * Created with IntelliJ IDEA.
 * Description:泛型的引入
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2023-09-14  11:40
 */
class Generics<T> {
    public Object[] array = new Object[10];

    public void setVal(int pos, T val) {
        this.array[pos] = val;
    }

    public T getPos(int pos) {
        return (T) this.array[pos];
    }
}
public class Test2 {
    public static void main(String[] args) {
        Generics<Integer> generics = new Generics<>();
        generics.setVal(0,100);
        generics.setVal(1,86);
        System.out.println(generics.getPos(0));
        System.out.println(generics.getPos(1));
    }
}

